home *** CD-ROM | disk | FTP | other *** search
/ Clipper Collection / Clipper Collection.iso / clipper7 / clipwind.arc / WN_SEARC.PRG < prev   
Text File  |  1988-03-14  |  5KB  |  121 lines

  1. ******************************************************************************
  2. ***** Module: WN_SEARC                                                   *****
  3. ***** Author: Jim Holley                                                 *****
  4. ***** Date  : 07/18/87                                                   *****
  5. ***** Comments:                                                          *****
  6. ***** This is an example program showing some features and uses of the   *****
  7. ***** Windows For Clipper Library. This routine performs a visual        *****
  8. ***** sequential search of the database. The search is performed once    *****
  9. ***** under program control and then under an operators control.         *****
  10. ***** The database used is the Customer.DBF file included with the       *****
  11. ***** Windows For Clipper package.                                       *****
  12. ******************************************************************************
  13. srch_cust = "Fox & Geller, Inc.            "
  14. CLEAR
  15. ***** create a window to display the search *****
  16. search_wn = _SINIT_WN(20,19,40,4)
  17. ***** set window border character *****
  18. _SST_WNBC(search_wn, 176)
  19. ***** we are not going to set the window colors *****
  20. ***** window is ready, open the data file *****
  21. USE customer
  22. ***** tell operator what we are doing.
  23. @ 01,18 SAY "╔═════════════════════════════════════════════╗"
  24. @ 02,18 SAY "║  This is a demonstration of the Windows     ║"
  25. @ 03,18 SAY "║  For Clipper routines. This module will     ║"
  26. @ 04,18 SAY "║  demonstrate the a visual sequential        ║"
  27. @ 05,18 SAY "║  search.                                    ║"
  28. @ 06,18 SAY "║                                             ║"
  29. @ 07,18 SAY "║                                             ║"
  30. @ 08,18 SAY "║                                             ║"
  31. @ 09,18 SAY "║                                             ║"
  32. @ 10,18 SAY "║                                             ║"
  33. @ 11,18 SAY "║                                             ║"
  34. @ 12,18 SAY "╚═════════════════════════════════════════════╝"
  35. ***** request a key press *****
  36. @ 10,25 SAY "Press any key to continue..."
  37. SET CONSOLE OFF
  38. WAIT
  39. SET CONSOLE ON
  40. @ 10,25 SAY "                             "
  41. ***** draw the window on the screen *****
  42. _SDRW_WN(search_wn)
  43. ***** now tell the operator that we are searching *****
  44. @ 11,35 SAY "Searching..."
  45. ***** set up the search algorythim *****
  46. DO WHILE .NOT. EOF()
  47.    ***** display the current customer name in search window *****
  48.    _SWTE_RECS(search_wn, comp_name)
  49.    ***** search conditions *****
  50.    IF comp_name = srch_cust
  51.       EXIT
  52.    ENDIF
  53.    ***** move to the next record *****
  54.    SKIP
  55. ENDDO
  56. @ 11,35 SAY "            "
  57. IF .NOT. EOF()
  58.    @ 9,25 SAY "Found at record " + LTRIM(STR(recno()))
  59. ELSE
  60.    @ 9,28 SAY "Customer Not Found."
  61. ENDIF
  62. ***** request a key press *****
  63. @ 10,25 SAY "Press any key to continue..."
  64. SET CONSOLE OFF
  65. WAIT
  66. SET CONSOLE ON
  67. @ 09,25 SAY "                             "
  68. @ 10,25 SAY "                             "
  69. ***** tell operator how to exit *****
  70. @ 7,25 SAY "Press The Escape Key To Exit."
  71. ***** erase the window from the screen *****
  72. _SWNERASE(search_wn)
  73. ***** Ok, set up for operator assisted search *****
  74. ***** set up infinite loop *****
  75. DO WHILE .T.
  76.    ***** reset record pointer. *****
  77.    GO TOP
  78.    ***** ask operator who to search for *****
  79.    @ 08,21 SAY "Please Enter the Customers Name to"
  80.    @ 09,21 SAY "search for :" GET srch_cust
  81.    READ
  82.    CLEAR GETS
  83.    ***** clear prompt portion of text.
  84.    @ 08,21 SAY "                                           "
  85.    @ 09,21 SAY "                                           "
  86.    ***** allow for a way to terminate the program *****
  87.    IF TRIM(srch_cust) < ' ' .OR. LASTKEY() = 27
  88.       EXIT
  89.    ENDIF
  90.    ***** draw the window on the screen *****
  91.    _SDRW_WN(search_wn)
  92.    @ 11,35 SAY "Searching..."
  93.    ***** set up the search algorythim *****
  94.    DO WHILE .NOT. EOF()
  95.       ***** display the current customer name in search window *****
  96.       _swte_recs(search_wn, comp_name)
  97.       ***** search conditions *****
  98.       IF comp_name = srch_cust
  99.          EXIT
  100.       ENDIF
  101.       ***** move to the next record *****
  102.       SKIP
  103.    ENDDO
  104.    @ 11,35 SAY "            "
  105.    IF .NOT. EOF()
  106.       @ 9,25 SAY "Found at record " + LTRIM(STR(recno()))
  107.    ELSE
  108.       @ 9,28 SAY "Customer Not Found."
  109.    ENDIF
  110.    ***** request a key press *****
  111.    @ 10,25 SAY "Press any key to continue..."
  112.    SET CONSOLE OFF
  113.    WAIT
  114.    SET CONSOLE ON
  115.    @ 09,25 SAY "                             "
  116.    @ 10,25 SAY "                             "
  117.    ***** erase the window from the screen *****
  118.    _SWNERASE(search_wn)
  119. ENDDO   
  120. RETURN
  121.